<?php /*a:2:{s:74:"D:\phpstudy_pro\WWW\www.xnadmin.site\app\admin\view\site_push\project.html";i:1621579286;s:63:"D:\phpstudy_pro\WWW\www.xnadmin.site\app\admin\view\iframe.html";i:1588058566;}*/ ?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title><?php echo xn_cfg('base.sys_name'); ?></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <script>
        //全局上传文件端口
        var UPLOAD_FILE_URL = "<?php echo url('upload_files/upload'); ?>";
        //全局选择文件端口
        var SELECT_FILE_URL = "<?php echo url('upload_files/select'); ?>";
    </script>
    <script src="/static/admin/js/jquery-2.0.0.min.js"></script>
    <script src="/static/admin/js/common.js"></script>
    <script src="/static/admin/js/upload.js"></script>
    <script src="/static/admin/js/webuploader.min.js"></script>
    <link rel="stylesheet" href="/static/admin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/admin/style/base.css" media="all">
    
    <style>
        .h15{height: 15px;}
    </style>
</head>
<body>
<div class="h15"></div>

<div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list" style="padding: 20px 30px 0 0;">
    <form action="<?php echo request()->url(); ?>" method="post" class="xn_ajax2" data-type="open">
        <blockquote class="layui-elem-quote layui-quote-nm">
            <div class="layui-form-item">
                <label class="layui-form-label">选择站点</label>
                <div class="layui-input-inline">
                    <select name="webid" id="webid">
                        <option value="0">请选择</option>
                        <?php if(is_array($weblist) || $weblist instanceof \think\Collection || $weblist instanceof \think\Paginator): if( count($weblist)==0 ) : echo "" ;else: foreach($weblist as $key=>$vo): ?>
                        <option value="<?php echo htmlentities($vo['id']); ?>"><?php echo htmlentities($vo['title']); ?></option>
                        <?php endforeach; endif; else: echo "" ;endif; ?>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">行业类型</label>
                <div class="layui-input-inline">
                    <select name="parent_typeid" lay-filter="parent_typeid" id="parent_typeid">
                        <option value="0">请选择</option>
                        <?php if(is_array($parent_typelist) || $parent_typelist instanceof \think\Collection || $parent_typelist instanceof \think\Paginator): if( count($parent_typelist)==0 ) : echo "" ;else: foreach($parent_typelist as $key=>$vo): ?>
                        <option value="<?php echo htmlentities($vo['id']); ?>" <?php if($data['parent_typeid'] == $vo['id']): ?>selected<?php endif; ?> ><?php echo htmlentities($vo['title']); ?></option>
                        <?php endforeach; endif; else: echo "" ;endif; ?>
                    </select>
                </div>
                <div class="layui-input-inline">
                    <select name="typeid" id="typeid">
                        <option value="0">请选择</option>
                        <?php if(is_array($typelist) || $typelist instanceof \think\Collection || $typelist instanceof \think\Paginator): if( count($typelist)==0 ) : echo "" ;else: foreach($typelist as $key=>$vo): ?>
                        <option value="<?php echo htmlentities($vo['id']); ?>" <?php if($data['typeid'] == $vo['id']): ?>selected<?php endif; ?> ><?php echo htmlentities($vo['title']); ?></option>
                        <?php endforeach; endif; else: echo "" ;endif; ?>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button type="button" class="layui-btn" onclick="getNum()">获取可推送数量</button>
                </div>
            </div>
        </blockquote>
        
        <div class="layui-form-item">
            <label class="layui-form-label">推送数量</label>
            <div class="layui-input-block layui-form-select">
                <input type="text" name="num" id="num" class="layui-input" value="" >
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="button" class="layui-btn" onclick="push()">推送</button>
            </div>
        </div>
        
    </form>
</div>


<script src="/static/admin/layui/layui.all.js"></script>
<script src="/static/admin/js/admin.js"></script>

<script>
    var form = layui.form;
    form.on('select(parent_typeid)', function(res) { 
        $("#typeid").empty();
        if(res.value != 0){
            $.get("<?php echo url('admin/DataType/getSonType'); ?>?pid="+res.value,function(result){
                if(result.status){
                    $("#typeid").append(new Option('请选择',0));
                    $.each(result.data,function(index,item){
                        $("#typeid").append(new Option(item.title,item.id));
                    });
                    form.render("select");
                }
            });
        }else{
            $("#typeid").append(new Option('请选择',0));
            form.render("select");
        }
    })

    function getNum(){
        var webid = $('#webid').val();
        var parent_typeid = $('#parent_typeid').val();
        var typeid = $('#typeid').val();
        $.get("<?php echo url('projectGetNum'); ?>",{webid:webid,parent_typeid:parent_typeid,typeid:typeid},function(res){
            layer.msg(res.msg,{time:1500});
            if(res.status){
                $('#num').val(res.data);
            }
        });
    }

    function push(count=0){
        var webid = $('#webid').val();
        var parent_typeid = $('#parent_typeid').val();
        var typeid = $('#typeid').val();
        var num = $('#num').val();
        if(count==0){
            layer.msg('开始执行', {icon: 1,time: 0});
        }
        $.get("<?php echo url('projectPush'); ?>",{webid:webid,parent_typeid:parent_typeid,typeid:typeid,num:num,count:count},function(res){
            if(res.status){
                layer.msg(res.msg, {icon: 1,time: 0}); 
                push(res.data.count);
            }else{
                layer.msg(res.msg, {icon: 1,time: 2000},function(){
                    location.reload();
                });
            }
        });
    }


</script>

</body>
</html>